package com.kaili.basic.controller.pda.v1;

import com.baomidou.mybatisplus.plugins.Page;
import com.kaili.basic.pojo.dto.BaseEmployeeQueryDto;
import com.kaili.basic.service.BaseEmployeeService;
import com.kaili.basic.version.ApiVersion;
import com.kaili.common.entity.BaseEmployee;
import com.kaili.common.exception.RestException;
import com.kaili.common.util.LoginDetailUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by rzh on 18-5-8.
 */
@ApiVersion(1)
@RequestMapping("/{api_version}")
@RestController("baseEmployeeControllerP")
@Api(tags = "[pda]员工管理", description = "[pda]员工管理相关API")
public class BaseEmployeeController {
    @Autowired
    private BaseEmployeeService baseEmployeeService;

    @ApiOperation(value = "查询员工", notes = "分页查员工")
    @GetMapping("p/baseEmployee")
    public Page<BaseEmployee> getCompany(@ModelAttribute BaseEmployeeQueryDto baseEmployeeQueryDto) throws RestException {
        BaseEmployee baseEmployee = new BaseEmployee();
        baseEmployee.setPage(baseEmployeeQueryDto.getPage());
        baseEmployee.setPageSize(baseEmployeeQueryDto.getPageSize());
        baseEmployee.setSiteId(baseEmployeeQueryDto.getSiteId());
        baseEmployee.setEmployeeName(baseEmployeeQueryDto.getEmployeeName());
        if(LoginDetailUtils.getSiteId()!=1)
            baseEmployee.setSiteId(LoginDetailUtils.getSiteId());
        return baseEmployeeService.selectByMap(new Page<BaseEmployee>(baseEmployee.getPage(), baseEmployee.getPageSize()), baseEmployee);
    }
}
